package com.dmall.algorithm.chapter01;

import java.util.Arrays;

public class Leetcode189V1 {

    public void rotate(int[] nums, int k) {
        for (int i = 0; i < k; i++) {
            int prev = nums[nums.length - 1];
            for (int j = 0; j < nums.length; j++) {
                int temp = nums[j];
                nums[j] = prev;
                prev = temp;
            }
        }
    }

    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5, 6, 7};
        Leetcode189V1 leetcode189 = new Leetcode189V1();
        leetcode189.rotate(nums, 3);
        System.out.println(Arrays.toString(nums));
    }
}
